package cc.wanforme.chipmunity.system.service.sync;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;

import cc.wanforme.chipmunity.common.consts.PassageEnum;
import cc.wanforme.chipmunity.system.event.SubjectEvent;
import cc.wanforme.chipmunity.system.mapper.PassageMapper;
import cc.wanforme.chipmunity.system.po.Subject;
/**
 * @author wanne
 * 2019年8月17日
 * 
 */
@Service
public class SubjectSyncService implements ApplicationListener<SubjectEvent>{

	@Autowired
	private PassageMapper passageMapper;
	
	//删除主题 - 文章状态
	@Override
	public void onApplicationEvent(SubjectEvent event) {
		Subject subject = (Subject) event.getSource();
		
		switch(event.getType()) {
			case DELETE: 
			case UPDATE_DELETE: 
				passageMapper.updatePassagesState( subject.getId(), PassageEnum.STATE_HIDE.getState());
				break;
			default:
				break;
		
		}
		
	}

}
